package backboneCode;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class GlobalStorage {
	
	private static Map<String, List<RuleSet>> ruleSet = new HashMap<String, List<RuleSet>>();
	private static Map<String, List<RuleSet>> systemRuleSet = new HashMap<String, List<RuleSet>>();
	private static List<Rules> notDefinedRules = new ArrayList<Rules>();
	public static boolean OnlyUseExplicitDefinedRules = false; 
	
	public static List<RuleSet> getRuleSet(String Key) {
		if (ruleSet.containsKey(Key))
			return ruleSet.get(Key);
		else
			return null;
	}
	
	public static Map<String, List<RuleSet>> getRuleSet() {
		return ruleSet;
	}
	
	public static List<RuleSet> getSystemRuleSet(String Key) {
		if (systemRuleSet.containsKey(Key))
			return systemRuleSet.get(Key);
		else
			return null;
	}
	
	public static Map<String, List<RuleSet>> getSystemRuleSet() {
		return systemRuleSet;
	}
	
	public static boolean addToRuleSet(String key, List<RuleSet> value) {
		if (!ruleSet.containsKey(key)) {
			ruleSet.put(key, value);
			return true;
		}
		return false;					
	}
	
	public static boolean addToSystemRuleSet(String key, List<RuleSet> value) {
		if (!systemRuleSet.containsKey(key)) {
			systemRuleSet.put(key, value);
			return true;
		}
		return false;					
	}
	
	public static void addToNotDefinedRules(Rules rule) {
		notDefinedRules.add(rule);
	}
	
	public static boolean ContainRule(Rules checkRule) {
		for (Rules rule : notDefinedRules) {
			if (rule.equals(checkRule))
				return true;
		}
		return false;
	}
	
	public static List<Rules> getNotDefinedRulesList() {
		return notDefinedRules;
	}
	
	public static Rules	getNotDefinedRule(Rules getRule) {
		for (Rules rule : notDefinedRules) {
			if (rule.equals(getRule))
				return rule;
		}
		return getRule; 
	}
}
